//
//  FFourCell.m
//  DemoTest
//
//  Created by DaShuEdu on 2017/5/5.
//  Copyright © 2017年 DaShuEdu. All rights reserved.
//

#import "FFourCell.h"

@implementation FFourCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        NSLog(@"%s",__func__);
        [self setupUI];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    NSLog(@"%s",__func__);
    [self setupUI];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    NSLog(@"%s",__func__);
    CGSize screenSize = self.bounds.size;
    CGPoint point = self.frame.origin;
    self.bounds = CGRectMake(0, 0, screenSize.width, self.titleLabel.bounds.size.height + 50);
    self.frame = CGRectMake(point.x, point.y, screenSize.width, self.titleLabel.bounds.size.height + 50);
}

- (void)setupUI {
    NSLog(@"%s",__func__);
    CGSize screenSize = self.bounds.size;
    self.headImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    [self.contentView addSubview:self.headImage];
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, screenSize.width, 40)];
    self.titleLabel.numberOfLines = 0;
    [self.contentView addSubview:self.titleLabel];
    
}

- (void)cellWithModel:(InfoCellModel *)model {
    self.titleLabel.text = model.title;
    self.headImage.image = [UIImage imageNamed:model.image];
    [self setNeedsLayout];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
